package com.xmy.cultivate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.Transcript;
import com.xmy.cultivate.mapper.TranscriptMapper;
import com.xmy.cultivate.service.ITranscriptService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 成绩管理 服务实现类
 * </p>
 *
 * @author hpiggy
 * @since 2024-03-20
 */
@Service
public class TranscriptServiceImpl extends ServiceImpl<TranscriptMapper, Transcript> implements ITranscriptService {

    @Override
    public Transcript getDataTranscript(Integer yearPart, Integer quarterNum, Long studentId, Long subjectsId, Integer examNum){
        QueryWrapper<Transcript> transcriptQueryWrapper = new QueryWrapper<>();
        transcriptQueryWrapper.eq("year_part",yearPart);
        transcriptQueryWrapper.eq("quarter_num",quarterNum);
        transcriptQueryWrapper.eq("exam_num",examNum);
        transcriptQueryWrapper.eq("student_id",studentId);
        transcriptQueryWrapper.eq("subjects_id",subjectsId);
        transcriptQueryWrapper.eq("is_statistics",1);
        transcriptQueryWrapper.last("limit 1");
        Transcript transcriptOne = this.getOne(transcriptQueryWrapper);
        return transcriptOne;
    }
}
